package com.danbay.cloud.deviceaccess.api.service;

import com.danbay.cloud.base.constants.Const;
import com.danbay.cloud.deviceaccess.api.dto.*;
import com.danbay.cloud.deviceaccess.api.dto.collector.*;
import com.danbay.cloud.deviceaccess.api.dto.lock.*;
import com.danbay.framework.exception.BusinessException;
import com.danbay.framework.springnc.annotation.AutoController;
import com.danbay.framework.springnc.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 下发控制设备服务
 * 同时接收下发控制返回数据
 *
 * @author SJG
 *         2017/11/08
 */
@AutoController
@RequestMapping("/device-access-service")
public interface ICtrlDeviceService {

    //////////////////////////////////////中控控制指令////////////////////////////////////////////////////

    /**
     * 允许入网
     * @param devId 中控设备id
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_ALLOW_AP, method = RequestMethod.POST)
    void sendAllow(String devId) throws BusinessException;

    /**
     * 允许入网中控回复
     * @param allowAp 允许入网回复信息
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_ALLOW_AP, method = RequestMethod.GET)
    void ackAllow(AllowAp allowAp) throws BusinessException;

    /**
     * 重启中控
     * @param devId 中控设备id
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_REBOOT, method = RequestMethod.POST)
    void sendRebootGateway(String devId) throws BusinessException;

    /**
     * 重启中控回复
     * @param rebootGw 重启中控回复信息
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_REBOOT, method = RequestMethod.GET)
    void ackRebootGateway(RebootGw rebootGw) throws BusinessException;

    ///////////////////////////////////////水电表控制指令/////////////////////////////////////////////////////////

    /**
     * 远程获取水表计量信息
     * @param devId 水表设备id
     * @throws BusinessException 业务异常
     */
//    @RequestMapping(value = Const.DEVICE_CTRL_GET_WATER, method = RequestMethod.POST)
//    void sendGetWaterData(String devId) throws BusinessException;

    /**
     * 远程获取水表计量信息
     * @param getWater 水表计量信息
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_WATER, method = RequestMethod.GET)
    void getWaterData(GetWater getWater) throws BusinessException;

    /**
     * 下发水电表取日冻结数据指令
     * @param devId 水表设备id
     * @param ymd   年月日,如171122
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_DAY_DATA, method = RequestMethod.POST)
    void sendGetDayData(@RequestParam("devId") String devId, @RequestParam("ymd") String ymd) throws BusinessException;

    /**
     * 上报水电表取日冻结数据
     * @param dayData 日冻结数据
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_DAY_DATA, method = RequestMethod.GET)
    void getDayData(GetDayData dayData) throws BusinessException;

    /**
     * 远程获取电表电能计量信息
     * @param devId 电表设备id
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_STATUS_KWH, method = RequestMethod.POST)
    void sendGetStatusKwh(WiredMeterNumber wiredMeterNumber, @RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程控制电表合闸命令
     * @param devId 电表设备id
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_EM_SWITCH_OPEN, method = RequestMethod.POST)
    void sendEmSwitchOpen(MeterOpen meterOpen, @RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程控制电表拉闸命令
     * @param devId 电表设备id
     * @throws BusinessException 业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_EM_SWITCH_CLOSE, method = RequestMethod.POST)
    void sendEmSwitchClose(@RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程获取电表电压测量信息
     * @param devId 电表设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_STATUS_VOLT,method = RequestMethod.GET)
    void getStatusVolt(@RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程获取电表瞬时功率
     * @param devId 电表设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_STATUS_POWER,method = RequestMethod.GET)
    void getStatusPower(@RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程获取电表电流测量信息
     * @param devId 电表设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_STATUS_CURRENT,method = RequestMethod.GET)
    void getStatusCurrent(@RequestParam("deviceId") String devId) throws BusinessException;

    /**
     * 云端远程获取电表瞬时功率
     * @param devId 电表设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_STATUS_PF,method = RequestMethod.GET)
    void getStatusPF(@RequestParam("deviceId") String devId) throws BusinessException;

    //////////////////////////////////////门锁控制指令/////////////////////////////////////////////////////////////

    /**
     * 新增门锁密码
     * @param newPwd   payload内容
     * @param deviceId 设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_ADD_NEW_PWD,method = RequestMethod.POST)
    void addNewPwd(@RequestBody NewPwd newPwd, @RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 修改门锁密码
     * @param editPwd  payload内容
     * @param deviceId 设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_UPDATE_PWD,method = RequestMethod.POST)
    void editPwd(EditPwd editPwd, @RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 删除门锁密码
     * @param delPwd   payload内容
     * @param deviceId 设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_DEL_PWD,method = RequestMethod.POST)
    void delPwd(DelPwd delPwd, @RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 停用/启用门锁密码
     * @param  stopPwd  payload内容
     * @param deviceId  设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_STOP_PWD,method = RequestMethod.POST)
    void stopPwd(StopPwd stopPwd,@RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 更新密码别名
     * @param updateAlias 更新密码别名内容
     * @param deviceId    设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_UPDATE_ALIAS,method = RequestMethod.POST)
    void updateAlias(@RequestParam("deviceId") String deviceId, UpdateAlias updateAlias) throws BusinessException;

    /**
     * 获取密码别名
     * @param deviceId  设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_GET_ALIAS,method = RequestMethod.GET)
    void getAlias(@RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 获取密码别名
     * @param alias  payload内容
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_LOCK_GET_ALIAS,method = RequestMethod.PUT)
    void getAlias(@RequestBody Alias alias) throws BusinessException;

    /////////////////////////////////////采集器////////////////////////////////////////////////////

    /**
     * 获取采集器下接档案数
     * @param deviceId 设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECTOR_GET_COUNT,method = RequestMethod.GET)
    void getCount(@RequestParam("deviceId") String deviceId) throws BusinessException;

    /**
     * 采集器电表获取日冻结数据
     * @param dailyData  payload内容
     * @param deviceId   设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECTOR_GET_DAILY_DATA,method = RequestMethod.GET)
    void getDailyData(GetDailyData dailyData,@RequestParam("deviceId")String deviceId)throws BusinessException;

    /**
     * 采集器获取电表整点冻结数据
     * @param dailyData  payload内容
     * @param deviceId 设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECTOR_GET_HOURLY_DATA,method = RequestMethod.GET)
    void getHourlyData(GetDailyData dailyData,@RequestParam("deviceId")String deviceId) throws BusinessException;

    /**
     * 远程获取采集器
     * @param getMeter  payload内容
     * @param deviceId  设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECTOR_GET_METER,method = RequestMethod.GET)
    void getMeter(GetMeter getMeter,@RequestParam("deviceId")String deviceId) throws BusinessException;


    /**
     * 远程增加电表采集器建档
     * @param wiredMeter  payload内容
     * @param deviceId    设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECTOR_ADD_METER,method = RequestMethod.POST)
    void addMeter(WiredMeter wiredMeter,@RequestParam("deviceId")String deviceId) throws BusinessException;

    /**
     * 采集器删除电表档案
     * @param wiredMeterAddr payload内容
     * @param deviceId       设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_COLLECROT__DEL_METER,method = RequestMethod.POST)
    void delMeter(WiredMeterAddr wiredMeterAddr,@RequestParam("deviceId")String deviceId) throws BusinessException;

    /**
     * 水表采集器获取水量信息
     * @param wiredMeterNumber  payload内容
     * @param deviceId          设备id
     * @throws BusinessException  业务异常
     */
    @RequestMapping(value = Const.DEVICE_CTRL_GET_WATER,method = RequestMethod.POST)
    void getWater(WiredMeterNumber wiredMeterNumber,@RequestParam("deviceId")String deviceId) throws BusinessException;
}
